<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>从小到大排序</title>
</head>
<body>
    <script>
        function sort(array) {
            array = array || [];
            for (var i = 0; i < array.length - 1; i++) {
                var isSort = true;
                for (var j = 0; j < array.length - 1 - i; j++) {
                    if (array[j] > array[j + 1]) {
                        var tmp = array[j];
                        array[j] = array[j + 1];
                        array[j + 1] = tmp;
                        isSort = false;
                    }
                }
                if (isSort) {
                    break;
                }
            }
            return array;
        }
        var array = [88,98,33,66,78,99];
        console.log(sort(array));
    </script>
</body>
</html>